<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"/>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>

<div th:insert="publicHeader.html"></div>
<script th:src="@{/publicHeader.js}"></script>

<div class="container-fluid" id="app" style="margin-top: 180px;margin-bottom: 100px">

    <div class="row">
        <div class="col-md-4">
            <div class="thumbnail">
                <img :src="weaponInfo.productImgsrc" alt="...">
            </div>
        </div>
        <div class= "col-md-8" style="font-size: 20px">
            <p>武器名称 : <span v-text="weaponInfo.productName"></span></p>
            <p>出售价格 : <span v-text="weaponInfo.productPrice" ></span></p>
            <p>上架时间 : <span v-text="weaponInfo.createdTime" ></span></p>
            <p>商品详情 : <span v-text="weaponInfo.detail" ></span></p>
            <br/>
            <br/>
            <br/>
            <a class="btn btn-success" >加入购物车</a>
        </div>
    </div>

</div>


<script>
    console.log("---单个武器---")
    let app = new Vue({
        el:"#app",
        data: {
            weaponId:-1,
            weaponInfo:{}
        },
        methods: {
            weaponsInfo(){
                let vueObj = this;
                $.post("/weapon/oneWeapon",{weaponId:this.weaponId},function (data) {
                    console.log(data);
                    vueObj.weaponInfo = data;
                })
            }
        },
        created() {
            let weaponId = sessionStorage.getItem("weaponId")
            console.log(weaponId);
            this.weaponId = weaponId;
            this.weaponsInfo();
        }
    })
</script>

<div th:insert="publicFooter.html"></div>

</body>
</html>